﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace BudgetKeeper
{
    public partial class MainForm : Form
    {
        Budget currentBudget;

        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           /* CurrentBudget = new Budget(28000);
            CurrentBudget.AddBudgetPost("Food", 2000);
            CurrentBudget.AddBudgetPost("Booze", 1000);

            CurrentBudget.AddExpense(0, "noodles", 125, "today");

            Debug.WriteLine(CurrentBudget.GetRemainingTotal());
            Debug.WriteLine(CurrentBudget.GetRemainingAfterBudget());
            Debug.WriteLine(CurrentBudget.GetIncome());
        */}

        private void addBudgetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddBudgetForm abf = new AddBudgetForm();
            abf.ShowDialog();

            if (abf.Completed)
            {
                currentBudget = new Budget(abf.Income);
            }
            abf.Dispose();
            debugOutput();
        }

        private void addBudgetPostToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (currentBudget != null)
            {
                AddBudgetPost abp = new AddBudgetPost();
                abp.ShowDialog();

                if (abp.Completed)
                {
                    currentBudget.AddBudgetPost(abp.Titel, abp.Sum);
                }
                abp.Dispose();
                debugOutput();
            }
            else
            {
                MessageBox.Show("Please create a budget first!", "Error!");
            }
        }

        private void addExpenseToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        public void debugOutput()
        {
            Debug.WriteLine("Remaining total: " + currentBudget.GetRemainingTotal());
            Debug.WriteLine("Remaining after budget: " + currentBudget.GetRemainingAfterBudget());
            Debug.WriteLine("Income: " + currentBudget.GetIncome());
        }

    }
}
